using System;
using System.ComponentModel;
using System.Drawing;
using System.Security.Permissions;
using System.Web;
using System.Web.UI;
using System.Drawing.Design;
using PickGold.Charting.Design;

namespace PickGold.Charting
{
	[SRDescription("DescriptionAttributeSmartLabelsStyle_SmartLabelsStyle")]
	[DefaultProperty("Enabled")]
	[TypeConverter(typeof(NoNameExpandableObjectConverter))]
	[AspNetHostingPermission(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
	[AspNetHostingPermission(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
	public class SmartLabelStyle
	{
		private LabelOutsidePlotAreaStyle _allowOutsidePlotArea;
		private Color _calloutBackColor;
		private LineAnchorCapStyle _calloutLineAnchorCapStyle;
		private Color _calloutLineColor;
		private ChartDashStyle _calloutLineDashStyle;
		private int _calloutLineWidth;
		private LabelCalloutStyle _calloutStyle;
		private bool _enabled;
		private bool _isMarkerOverlappingAllowed;
		private bool _isOverlappedHidden;
		private double _maxMovingDistance;
		private double _minMovingDistance;
		private LabelAlignmentStyles _movingDirection;
		internal object chartElement;

		public SmartLabelStyle()
		{
			this._enabled = true;
			this._isOverlappedHidden = true;
			this._movingDirection = LabelAlignmentStyles.BottomRight | LabelAlignmentStyles.BottomLeft | LabelAlignmentStyles.TopRight | LabelAlignmentStyles.TopLeft | LabelAlignmentStyles.Left | LabelAlignmentStyles.Right | LabelAlignmentStyles.Bottom | LabelAlignmentStyles.Top;
			this._maxMovingDistance = 30.0;
			this._allowOutsidePlotArea = LabelOutsidePlotAreaStyle.Partial;
			this._calloutStyle = LabelCalloutStyle.Underlined;
			this._calloutLineColor = Color.Black;
			this._calloutLineDashStyle = ChartDashStyle.Solid;
			this._calloutBackColor = Color.Transparent;
			this._calloutLineWidth = 1;
			this._calloutLineAnchorCapStyle = LineAnchorCapStyle.Arrow;
			this.chartElement = null;
		}

		internal SmartLabelStyle(object chartElement)
		{
			this._enabled = true;
			this._isOverlappedHidden = true;
			this._movingDirection = LabelAlignmentStyles.BottomRight | LabelAlignmentStyles.BottomLeft | LabelAlignmentStyles.TopRight | LabelAlignmentStyles.TopLeft | LabelAlignmentStyles.Left | LabelAlignmentStyles.Right | LabelAlignmentStyles.Bottom | LabelAlignmentStyles.Top;
			this._maxMovingDistance = 30.0;
			this._allowOutsidePlotArea = LabelOutsidePlotAreaStyle.Partial;
			this._calloutStyle = LabelCalloutStyle.Underlined;
			this._calloutLineColor = Color.Black;
			this._calloutLineDashStyle = ChartDashStyle.Solid;
			this._calloutBackColor = Color.Transparent;
			this._calloutLineWidth = 1;
			this._calloutLineAnchorCapStyle = LineAnchorCapStyle.Arrow;
			this.chartElement = chartElement;
		}

		private void Invalidate()
		{
			if (this.chartElement != null)
			{
				if (this.chartElement is Series)
				{
					((Series)this.chartElement).Invalidate(false, false);
				}
				else if (this.chartElement is Annotation)
				{
					((Annotation)this.chartElement).Invalidate();
				}
			}
		}

		[SRDescription("DescriptionAttributeAllowOutsidePlotArea")]
		[Bindable(true)]
		[DefaultValue(2)]
		[SRCategory("CategoryAttributeMisc")]
		public virtual LabelOutsidePlotAreaStyle AllowOutsidePlotArea
		{
			get
			{
				return this._allowOutsidePlotArea;
			}
			set
			{
				this._allowOutsidePlotArea = value;
				this.Invalidate();
			}
		}

		[Editor(typeof(ChartColorEditor), typeof(UITypeEditor))]
		[TypeConverter(typeof(ColorConverter))]
		[SRCategory("CategoryAttributeAppearance")]
		[Bindable(true)]
		[DefaultValue(typeof(Color), "Transparent")]
		[SRDescription("DescriptionAttributeCalloutBackColor")]
		public virtual Color CalloutBackColor
		{
			get
			{
				return this._calloutBackColor;
			}
			set
			{
				this._calloutBackColor = value;
				this.Invalidate();
			}
		}

		[Bindable(true)]
		[DefaultValue(1)]
		[SRDescription("DescriptionAttributeCalloutLineAnchorCap")]
		[SRCategory("CategoryAttributeAppearance")]
		public virtual LineAnchorCapStyle CalloutLineAnchorCapStyle
		{
			get
			{
				return this._calloutLineAnchorCapStyle;
			}
			set
			{
				this._calloutLineAnchorCapStyle = value;
				this.Invalidate();
			}
		}

		[SRCategory("CategoryAttributeAppearance")]
		[TypeConverter(typeof(ColorConverter))]
		[Editor(typeof(ChartColorEditor), typeof(UITypeEditor))]
		[Bindable(true)]
		[DefaultValue(typeof(Color), "Black")]
		[SRDescription("DescriptionAttributeCalloutLineColor")]
		public virtual Color CalloutLineColor
		{
			get
			{
				return this._calloutLineColor;
			}
			set
			{
				this._calloutLineColor = value;
				this.Invalidate();
			}
		}

		[SRCategory("CategoryAttributeAppearance")]
		[SRDescription("DescriptionAttributeLineDashStyle")]
		[PersistenceMode(PersistenceMode.Attribute)]
		[Bindable(true)]
		[DefaultValue(5)]
		public virtual ChartDashStyle CalloutLineDashStyle
		{
			get
			{
				return this._calloutLineDashStyle;
			}
			set
			{
				this._calloutLineDashStyle = value;
				this.Invalidate();
			}
		}

		[SRDescription("DescriptionAttributeLineWidth")]
		[SRCategory("CategoryAttributeAppearance")]
		[Bindable(true)]
		[DefaultValue(1)]
		public virtual int CalloutLineWidth
		{
			get
			{
				return this._calloutLineWidth;
			}
			set
			{
				this._calloutLineWidth = value;
				this.Invalidate();
			}
		}

		[Bindable(true)]
		[SRCategory("CategoryAttributeMisc")]
		[DefaultValue(1)]
		[SRDescription("DescriptionAttributeCalloutStyle3")]
		public virtual LabelCalloutStyle CalloutStyle
		{
			get
			{
				return this._calloutStyle;
			}
			set
			{
				this._calloutStyle = value;
				this.Invalidate();
			}
		}

		[Bindable(true)]
		[SRCategory("CategoryAttributeMisc")]
		[DefaultValue(true)]
		[SRDescription("DescriptionAttributeEnabled13")]
		[ParenthesizePropertyName(true)]
		public virtual bool Enabled
		{
			get
			{
				return this._enabled;
			}
			set
			{
				this._enabled = value;
				this.Invalidate();
			}
		}

		[Bindable(true)]
		[SRCategory("CategoryAttributeMisc")]
		[DefaultValue(false)]
		[SRDescription("DescriptionAttributeMarkerOverlapping")]
		public virtual bool IsMarkerOverlappingAllowed
		{
			get
			{
				return this._isMarkerOverlappingAllowed;
			}
			set
			{
				this._isMarkerOverlappingAllowed = value;
				this.Invalidate();
			}
		}

		[SRCategory("CategoryAttributeMisc")]
		[Bindable(true)]
		[DefaultValue(true)]
		[SRDescription("DescriptionAttributeHideOverlapped")]
		public virtual bool IsOverlappedHidden
		{
			get
			{
				return this._isOverlappedHidden;
			}
			set
			{
				this._isOverlappedHidden = value;
				this.Invalidate();
			}
		}

		[SRCategory("CategoryAttributeMisc")]
		[Bindable(true)]
		[DefaultValue((double)30.0)]
		[SRDescription("DescriptionAttributeMaxMovingDistance")]
		public virtual double MaxMovingDistance
		{
			get
			{
				return this._maxMovingDistance;
			}
			set
			{
				if (value < 0.0)
				{
					throw new InvalidOperationException(SR.ExceptionSmartLabelsMaxMovingDistanceIsNegative);
				}
				this._maxMovingDistance = value;
				this.Invalidate();
			}
		}

		[Bindable(true)]
		[SRCategory("CategoryAttributeMisc")]
		[DefaultValue((double)0.0)]
		[SRDescription("DescriptionAttributeMinMovingDistance")]
		public virtual double MinMovingDistance
		{
			get
			{
				return this._minMovingDistance;
			}
			set
			{
				if (value < 0.0)
				{
					throw new InvalidOperationException(SR.ExceptionSmartLabelsMinMovingDistanceIsNegative);
				}
				this._minMovingDistance = value;
				this.Invalidate();
			}
		}

		[SRCategory("CategoryAttributeMisc")]
		[Bindable(true)]
		[DefaultValue(typeof(LabelAlignmentStyles), "Top, Bottom, Right, Left, TopLeft, TopRight, BottomLeft, BottomRight")]
		[SRDescription("DescriptionAttributeMovingDirection")]
		[Editor(typeof(FlagsEnumUITypeEditor), typeof(UITypeEditor))]
		public virtual LabelAlignmentStyles MovingDirection
		{
			get
			{
				return this._movingDirection;
			}
			set
			{
				if (value == 0)
				{
					throw new InvalidOperationException(SR.ExceptionSmartLabelsDirectionUndefined);
				}
				this._movingDirection = value;
				this.Invalidate();
			}
		}
	}
}

